/*
 * @lc app=leetcode.cn id=1413 lang=typescript
 *
 * [1413] 逐步求和得到正数的最小值
 */

// @lc code=start
function minStartValue(nums: number[]): number {
    let min = Infinity;

    nums.reduce((col, cur) => {
        const result = col + cur;
        if (result < min) min = result;
        return result;
    }, 0);
    return min >= 0 ? 1 : Math.abs(min) + 1;
}
// @lc code=end
